<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVehiclesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('vehicles', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('vehicle_series_id')->comment('系列ID');
            $table->foreign('vehicle_series_id')->references('id')->on('vehicle_series')->onDelete('cascade');
            $table->unsignedBigInteger('activity_id')->nullable()->comment('活动ID');
            $table->foreign('activity_id')->references('id')->on('activities')->onDelete('set null');
            $table->string('name',50)->comment('车型名');
            $table->string('code',20)->unique()->comment('车型编号');
            $table->string('img_url')->comment('展示图');
            $table->string('min_img_url')->comment('展示小图');
            $table->text('describe')->comment('描述');
            $table->integer('order')->unsigned()->default(0)->comment('排序');
            $table->boolean('recommend')->comment('首页推荐');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('vehicles');
    }
}
